import { Http } from "@/utils/request";
import { Toast } from "@/utils/toast";
import { delayTask } from "@/utils/timer";

const baseUrl = "/new_guide_sachet";

export const index_api = (data: { cate_id: string }, showError = true) => {
  return Http.get<{ header: any; list: { items: any[] } }>(
    `/v3${baseUrl}/index`,
    data
  ).catch((error: Error) => {
    showError && delayTask(60, () => Toast.show(error.message));
    return Promise.reject(error);
  });
};

export const info_api = (data: { id: string }, showError = true) => {
  return Http.get<any>(`/v3${baseUrl}/info`, data).catch((error: Error) => {
    showError && delayTask(60, () => Toast.show(error.message));
    return Promise.reject(error);
  });
};
